home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
bc7eqget.zip
/
BC7EQGET.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-03-27
|
7KB
|
204 lines
' BC7EqGet.Bas 03-26-90 Use Interrupt in MS Basic 7.x
' ------------ Remember to invoke QBX fn /lQBX <-- Note !
' Author: T. E. McCormick
' Liberal use of two functions in QB4INT.ZIP by author unknown:
DECLARE SUB IntToBin (Byte%, Bin$)
' IntToBin() ...creates binary bit display string
DECLARE SUB Breakword (dataword%, highbyte%, lowbyte%)
' BreakWord() ...breaks 16 bit reg into two 8 bit variables
'$INCLUDE: 'QBX.BI'
DIM inregs AS RegType, outregs AS RegType
DEFINT A-Z
False% = 0: True% = -1
CLS
'---------------------------------------------------------------------
'----- EXAMPLES USING `INTERRUPT` WITH MS BASIC VER. 7.X -----
'----- NOTE: Function hex values go in the HIGH Byte of AX -----
'---------------------------------------------------------------------
Peripherals:
inregs.AX = &H1100
Interrupt &H11, inregs, outregs ' 11: Peripheral Equip Installed
I.Word% = outregs.AX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "AX": GOSUB I.ShowRegReturn ' Debugging
CALL IntToBin(High%, High$) ' Bit Strings
CALL IntToBin(Low%, Low$)
W.Bits$ = LEFT$(High$, 2) ' bits e and f are highest
IF W.Bits$ = "00" THEN I.ParPrinters% = 0 ' Parallel printer(s)
IF W.Bits$ = "01" THEN I.ParPrinters% = 1
IF W.Bits$ = "10" THEN I.ParPrinters% = 2
IF W.Bits$ = "11" THEN I.ParPrinters% = 3
IF MID$(High$, 4, 1) = "1" THEN
I.GamePorts% = 1
ELSE I.GamePorts% = 0
END IF
W.Bits$ = MID$(High$, 5, 3)
IF W.Bits$ = "000" THEN I.SerialPorts% = 0
IF W.Bits$ = "001" THEN I.SerialPorts% = 1
IF W.Bits$ = "010" THEN I.SerialPorts% = 2
IF W.Bits$ = "011" THEN I.SerialPorts% = 3
IF W.Bits$ = "100" THEN I.SerialPorts% = 4
W.Bits$ = LEFT$(Low$, 2)
IF RIGHT$(Low$, 1) = "0" THEN
I.DisketteDrives% = 0
ELSE
IF W.Bits$ = "00" THEN I.DisketteDrives% = 1
IF W.Bits$ = "01" THEN I.DisketteDrives% = 2
IF W.Bits$ = "10" THEN I.DisketteDrives% = 3
IF W.Bits$ = "11" THEN I.DisketteDrives% = 4
END IF
IF MID$(Low$, 7, 1) = "1" THEN
I.CoProcessor% = 1
ELSE I.CoProcessor% = 0
END IF
GetDate:
inregs.AX = &H2A00 ' Get Date (& Day of Week 0-6 Sun-Sat)
Interrupt &H21, inregs, outregs ' 21: DOS Services
I.DayOfWeek$ = "Sunday Monday Tuesday Wednesday"
I.DayOfWeek$ = I.DayOfWeek$ + "Thurdsay Friday Saturday "
I.Word% = outregs.AX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "AX": GOSUB I.ShowRegReturn ' Debugging
Temp% = ((Low% + 1) * 9) - 8 ' 1st letter
I.WeekDay$ = MID$(I.DayOfWeek$, Temp%, 9)
I.WeekDay$ = RTRIM$(I.WeekDay$)
I.WeekdayAbbrev$ = LEFT$(I.WeekDay$, 3)
I.Year% = outregs.cx ' Year range 1980 - 2099
I.Word% = outregs.DX ' Month and Day
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "DX": GOSUB I.ShowRegReturn ' Debugging
I.Month% = High%
I.Day% = Low%
GetDosVersion:
inregs.AX = &H3000 ' Get Current DOS Major & Minor Ver.
Interrupt &H21, inregs, outregs ' 21: DOS Services
I.Word% = outregs.AX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "AX": GOSUB I.ShowRegReturn ' Debugging
I.DosMajor% = Low%
I.DosMinor% = High%
I.DosVer$ = LTRIM$(STR$(Low%)) + "." + LTRIM$(STR$(High%))
GetVideoMode:
inregs.AX = &HF00 ' Get Current Video Mode
Interrupt &H10, inregs, outregs ' 10: Video I/O ROM BIOS
I.Word% = outregs.AX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "AX": GOSUB I.ShowRegReturn ' Debugging
I.Columns% = Low%
I.CurVideoMode% = High%
IF I.CurVideoMode% = 7 THEN
I.CrtColor% = False%
ELSE I.CrtColor% = True%
END IF
GetCursorPosition:
inregs.AX = &H300 ' Get Current Cursor Row & Column
Interrupt &H10, inregs, outregs ' 10: Video I/O ROM BIOS
I.Word% = outregs.DX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "DX": GOSUB I.ShowRegReturn ' Debugging
I.CursorColumn% = Low% + 1 ' Returns 0-39, 0-79, etc.
I.CursorRow% = High% + 1 ' Returns 0-24, etc.
HighMemory:
inregs.AX = &H8800
Interrupt &H15, inregs, outregs ' 15: Hi Mem 1k blocks above 640 k
I.MemHigh% = outregs.AX
I.Word% = outregs.AX
CALL Breakword(I.Word%, High%, Low%)
I.Reg$ = "AX": GOSUB I.ShowRegReturn ' Debugging
GOSUB I.ShowVariables
SYSTEM
'----------------------------------------------------------------------
'I.ShowRegReturn: Subroutine to display high and low of any
'---------------- 16 bit register returned after INTERRUPT.
'Place 16 bit register value in I.Word% before GOSUB:
' for example I.Word% = outregs.ax
'Place 2-character register ID in I.Reg$ before GOSUB:
' for example I.Reg$ = "AX"
'----------------------------------------------------------------------
I.ShowRegReturn:
PRINT STRING$(39, 196) ' Divider bar for readability
CALL Breakword(I.Word%, High%, Low%)
PRINT I.Reg$; " Reg: "; I.Word%; TAB(16);
PRINT " High="; High; " Low="; Low
CALL IntToBin(High%, High$)
CALL IntToBin(Low%, Low$)
PRINT " fedcba98 76543210 "
PRINT I.Reg$; " bit string: "; High$; " "; Low$
RETURN
'------
I.ShowVariables:
PRINT "Press ENTER to see variables contents: ";
INPUT "", Dummy$
CLS
PRINT "Parallel Printer Port(s).......... : "; I.ParPrinters%
PRINT "Serial Port(s).................... : "; I.SerialPorts%
PRINT "Diskette drive(s)................. : "; I.DisketteDrives%
PRINT "Game Port? 0=No................... : "; I.GamePorts%
PRINT "80x87 Math Coprocessor? 0=No...... : "; I.CoProcessor%
PRINT "Day of Week, Month, Day, Year..... : ";
PRINT I.WeekDay$; " "; I.Month%; " "; I.Day%; " "; I.Year%
PRINT "DOS Major and Minor versions...... : "; I.DosVer$
PRINT "Color or Monochrome? 0=Mono....... : "; I.CrtColor%
PRINT "Memory above 640k (in k).......... : "; I.MemHigh%
RETURN
'------
'_____________________________________________________________________
'
' BreakWord() takes an integer argument and returns two integers
' representing the high and low bytes of the original.
'_____________________________________________________________________
'
SUB Breakword (dataword, highbyte, lowbyte)
IF dataword < 0 THEN
highbyte = (dataword + 2 ^ 16) \ 256 'check for high BIT set
ELSE highbyte = dataword \ 256 'integer divide off low byte
END IF
lowbyte = dataword AND 255 'AND off the top byte
END SUB
'_____________________________________________________________________
'
' IntToBin() takes an INTEGER argument and produces a
' binary string representation of the INTEGER.
'_____________________________________________________________________
'
SUB IntToBin (Byte%, Bin$)
Bin$ = ""
Temp% = Byte%
FOR I = 0 TO 7
IF Temp% AND 1 THEN
Bin$ = "1" + Bin$
ELSE
Bin$ = "0" + Bin$
END IF
Temp% = Temp% \ 2
NEXT
END SUB